package com.nbsaas.boot.marketing.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "优惠券", model = "优惠券")
@Entity
@Table(name = "bs_coupon")
@Comment("优惠券主表")
public class Coupon extends AbstractEntity {

    @Comment("优惠券名称")
    @SearchItem(name = "name", key = "name", label = "优惠券名称")
    @FormField(title = "优惠券名称", sortNum = "1", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String name;

    @Comment("优惠券编码")
    @SearchItem(name = "code", key = "code", label = "优惠券编码")
    @FormField(title = "优惠券编码", sortNum = "2", grid = true)
    @Column(length = 50, unique = true)
    private String code;

    @Comment("优惠券类型")
    @SearchItem(name = "type", key = "type", label = "优惠券类型")
    @FormField(title = "优惠券类型", sortNum = "3", grid = true, type = InputType.select, option = "coupon_type")
    @Column(length = 20)
    private String type;

    @Comment("折扣类型")
    @FormField(title = "折扣类型", sortNum = "4", grid = true, type = InputType.select, option = "discount_type")
    @Column(length = 20)
    private String discountType;

    @Comment("折扣值")
    @FormField(title = "折扣值", sortNum = "5", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal discountValue;

    @Comment("最低消费金额")
    @FormField(title = "最低消费金额", sortNum = "6", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal minAmount;

    @Comment("最大优惠金额")
    @FormField(title = "最大优惠金额", sortNum = "7", grid = true, type = InputType.el_input_number)
    @Column(precision = 10, scale = 2)
    private BigDecimal maxDiscount;

    @Comment("发放总数")
    @FormField(title = "发放总数", sortNum = "8", grid = true, type = InputType.el_input_number)
    private Integer totalCount;

    @Comment("已使用数量")
    @FormField(title = "已使用数量", sortNum = "9", grid = true, type = InputType.el_input_number)
    private Integer usedCount;

    @Comment("每人限领数量")
    @FormField(title = "每人限领数量", sortNum = "10", grid = true, type = InputType.el_input_number)
    private Integer perLimit;

    @Comment("开始时间")
    @FormField(title = "开始时间", sortNum = "11", grid = true, type = InputType.date)
    private LocalDateTime startTime;

    @Comment("结束时间")
    @FormField(title = "结束时间", sortNum = "12", grid = true, type = InputType.date)
    private LocalDateTime endTime;

    @Comment("有效天数")
    @FormField(title = "有效天数", sortNum = "13", grid = true, type = InputType.el_input_number)
    private Integer validDays;

    @Comment("状态")
    @SearchItem(name = "status", key = "status", label = "状态")
    @FormField(title = "状态", sortNum = "14", grid = true, type = InputType.select, option = "coupon_status")
    @Column(length = 20)
    private String status;

    @Comment("使用说明")
    @FormField(title = "使用说明", sortNum = "15", type = InputType.textarea, col = 23)
    @Column(columnDefinition = "text")
    private String description;

    @Comment("使用条款")
    @FormField(title = "使用条款", sortNum = "16", type = InputType.richText, col = 23)
    @Column(columnDefinition = "text")
    private String terms;
} 